package com.lnlyj.media.demo;

import android.Manifest;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.lnlyj.media.Config;
import com.lnlyj.media.LnlyjSelector;
import com.lnlyj.media.ResultData;

import java.util.List;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import static com.lnlyj.media.Constants.EXTRA_RESULT_DATA;
import static com.lnlyj.media.Constants.REQUEST_CODE_MEDIA;

public class MainActivity extends AppCompatActivity {

    public static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void onClick(View view) {
        LnlyjSelector.getInstance().selector(this);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE_MEDIA) {
            if (resultCode == RESULT_OK) {
                List<ResultData> list = data.getParcelableArrayListExtra(EXTRA_RESULT_DATA);

                for (ResultData d : list) {
                    // 路径
                    Log.e(TAG, "path = " + d.getPath());
                    // file数据库的uri
                    Log.e(TAG, "path = " + d.getUri());
                    // 是否是原图发送
                    Log.e(TAG, "fullImage = " + d.isFullImage());
                }
            }
        }
    }
}
